<template>
  <view class="main">

	  <view class="part2">
	  		  <view class="pp1">提现方式</view>
               <picker @change="bindPickerChange" :value="typeid" :range="txtype" mode="selector">
				 <view class="uni-input">{{txtype[typeid]}}</view>
			   </picker>
	  </view>


	  <view class="part2">
	  		  <view class="pp1">身份证号</view>
	  		  <input type="text" placeholder="请填写正确的身份证号" v-model="sfz"></input>
	  </view>
	  	
	  <view class="part2">
	  		  <view class="pp1">手机号</view>
	  		  <input type="text" placeholder="请填写正确的手机号码" v-model="phone"></input>
	  </view>	
	
	  <block v-if="typeid==3">
	  <view class="part2">
	  		  <view class="pp1">持卡人姓名</view>
	  		  <input type="text" placeholder="姓名必须和银行卡绑定" v-model="xm"></input>
	  </view>	
	  <view class="part2">
	  		  <view class="pp1">银行卡号</view>
	  		  <input type="text" placeholder="请输入银行卡号" v-model="cardnum"></input>
	  </view>			  
	 </block> 
	 
	  <block v-if="typeid==1">
	  <view class="part2">
	  		  <view class="pp1">真实姓名</view>
	  		  <input type="text" placeholder="请输入姓名" v-model="xm"></input>
	  </view>	
	  <view class="part2">
	  		  <view class="pp1">微信号</view>
	  		  <input type="text" placeholder="请输入微信号" v-model="wxh"></input>
	  </view>			  
	 </block> 	 
	 
	<block v-if="typeid==2">
	 <view class="part2">
	 		  <view class="pp1">真实姓名</view>
	 		  <input type="text" placeholder="请输入姓名" v-model="xm"></input>
	 </view>	
	 <view class="part2">
	 		  <view class="pp1">支付账号</view>
	 		  <input type="text" placeholder="请输入支付宝账号" v-model="zfb"></input>
	 </view>			  
	</block> 
	 
	 
	 
		  	  
	  <view class="part2">
		  <view class="pp1">提现金额</view>
		  <input type="text" placeholder="请输入提现金额" v-model="gmoney"></input>
	  </view>		
	
	  <view class="tips">
		  当前可提现的金额 <span class="cmeny">{{wallet.user_money || 0}}元</span>，冻结金额：0元<br>
		  说明：正常情况，提现申请每月15号到账。
	  </view>
	  <view class="txbtn" @click="submittx()">提现</view>
	  
  </view>
</template>

<script>
import { getWallet,submittx } from '../../api/user';
export default {
  data() {
    return {
	  wallet: {},
      typeid: 0,
      txtype: ['选择提现方式','微信','支付宝','银行卡'],
	  xm:"",
	  sfz:"",
	  phone:"",
	  cardnum:"",
	  zfb:"",
	  wxh:"",
	  gmoney:""
    };
  },

  components: {
    // recommend
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getWalletFun();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},
  methods: {
     bindPickerChange(e){
	  this.typeid=e.detail.value;	
	},
	getWalletFun() {
	  getWallet().then(res => {
	    if (res.code == 1) {
	        this.wallet = res.data;
	    }
	  });
	},
	submittx(){
	  var typeid=this.typeid;
	  var sfz=this.sfz;
	  var phone=this.phone;
	  var xm=this.xm;
	  var cardnum=this.cardnum;
	  var zfb=this.zfb;
	  var wxh=this.wxh;
	  var gmoney=this.gmoney;
	  console.log(xm);
	  if(typeid==0){uni.showToast({icon:"none",title:"请选择提现方式"});return false;}
	  if(sfz==''){uni.showToast({icon:"none",title:"请输入身份证号码"});return false;}
	  if(phone==''){uni.showToast({icon:"none",title:"请输入电话号码"});return false;}
	  if(xm==''){uni.showToast({icon:"none",title:"请输入您的真实姓名"});return false;}
	  if(typeid==1){
		if(wxh==''){uni.showToast({icon:"none",title:"请输入您的微信号"});return false;}  
	  }
	  if(typeid==2){
	  	if(zfb==''){uni.showToast({icon:"none",title:"请输入您的支付宝账号"});return false;}  
	  }
	  if(typeid==3){
	  	if(cardnum==''){uni.showToast({icon:"none",title:"请输入您的银行卡号"});return false;}  
	  }
	  if(gmoney==''){uni.showToast({icon:"none",title:"请输入您要提现的金额"});return false;}
	  submittx({
		typeid:typeid,
		sfz:sfz,
		phone:phone,
		xm:xm,
		cardnum:cardnum,
		gmoney:gmoney,
		zfb:zfb,
		wxh:wxh  
	  }).then(res => {
	    if (res.code == 1) {
	     uni.showToast({
	        icon:"none",
			title:"申请提现成功"
	     })  
		 uni.navigateTo({
		 	url:"/pages/user_wallet/user_wallet"
		 })
	    }
	  });	   
	}
  }
};
</script>

<style>
	.pp1{font-size:30rpx; padding-right:40rpx;}
	.main{width:750rpx;background-color: white;padding-bottom:100rpx;}
	.part2{
	  width:690rpx;
	  height:120rpx;
	  display:flex;
	  align-items: center;
	  margin:0 auto;
	  border-bottom:1rpx solid grey;
	}
	.tips{
		width:690rpx;
		margin:0 auto;
		color:grey;
		line-height:60rpx;
	}
	.cmeny{color:rgb(255, 44, 60);}
	.txbtn{
	  width:690rpx;
	  margin:0 auto;
	  height:80rpx;
	  color:white;
	  background-color: rgb(255, 44, 60);
	  display:flex;
	  align-items:center;
	  border-radius:20rpx;
	  justify-content: center;
	  font-weight:bold;
	  font-size:35rpx;
	  margin-top:40rpx;
	}
</style>